package com.rabbitmq.learn.work.fair;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.learn.common.ConnectionUtils;
import com.rabbitmq.learn.common.RabbitMqConstant;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * Created by Lxk on 2019/8/11.
 */
public class Sender {

    public static void main(String[] args) throws IOException, TimeoutException, InterruptedException {
        Connection con = ConnectionUtils.getConnection();

        Channel channel = con.createChannel();

        channel.queueDeclare(RabbitMqConstant.Work.QUEUE_NAME,false,false,false,null);

        for(int i = 0;i < 100; i++){
            String msg = "hello work " + i;
            channel.basicPublish("",RabbitMqConstant.Work.QUEUE_NAME,null,msg.getBytes());
            System.out.println(msg + "send success");
            Thread.sleep(25);
        }

        channel.close();

        con.close();

    }

}
